import riskClient from "./riskClient";

export const findEmerManagement = async (params) => {
  return await riskClient.postAsync({
    url: 'api/emerMatter/findEmerManagement',
    params,
  })
}

export const addAndEditEmerBuildMsg = async (params) => {
  return await riskClient.postAsync({
    url: 'api/emerMatter/addAndEditEmerBuildMsg',
    params,
  })
}

export const findEmerMsgDetails = async (params) => {
  return await riskClient.postAsync({
    url: 'api/emerMatter/findEmerMsgDetails',
    params,
  })
}

export const auditEmerMsg = async (params) => {
  return await riskClient.postAsync({
    url: 'api/emerMatter/auditEmerMsg',
    params,
  })
}

export const findEmerMasterList = async (params) => {
  const {data, error} = await riskClient.getAsync({
    url: 'api/emerMatter/findEmerMasterList',
    params,
    restfull: false
  })
  if (error) return []

  const MasterList = data?.map((item) => ({
      value: item.emerMasterId,
      label: item.emerName,
      unitCode: item.unitCode,
      unitName: item.unitName,
    }))

  return MasterList
}
